package com.mingserve.common.mybatis.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

/**
 * MP 注入处理器
 *
 * @author lvwshuai
 * @date 2024-01-31
 */
@Slf4j
@Component
public class InjectionMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
//        log.info("start insert fill...");
        this.setFieldValByName("createTime", System.currentTimeMillis(), metaObject);
        this.setFieldValByName("updateTime", System.currentTimeMillis(), metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
//        log.info("start update fill...");
        this.setFieldValByName("updateTime",  System.currentTimeMillis(), metaObject);
    }
}